<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<title>Database Performance Dashboard</title>
<script src="js/jquery-1.2.3.pack.js"></script>
<script src="js/runonload.js"></script>
<script src="js/tutorial.js"></script>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
</head>
<!-- include all library files here -->
<?php require_once "./bootstrap.php"; ?>
<?php
	date_default_timezone_set("Asia/Singapore");
?> 


<!-- get performance data -->
<?php
	if(!isset($_SESSION['user']) || $_SESSION['user']==NULL)
		header('Location: index.php');
		
	$urs_config = new UserConfig($_SESSION['user']);
	//var_dump($urs_config->getFirst('PCT_FREE_MEM'));
	
?>


<body>
	<div id="container">
	<!-- Start of Page Header -->
		<div id="page_header">
			<div id="company_name">
				<h1><span>Oracle Database Performance Dashboard</span></h1>
			</div>
		</div>
		<div id="page_menu">
			<ul>
				<li class="home"><a href="./index.php" title="Home"><span>Home</span></a></li>
				<li class="monitor"><a href="./firstlevel.php" title="First Level of Parameters Monitor"><span>Monitor</span></a></li>
				<li class="debug"><a href="./debug.php" title="Debug Interface"><span>Debug</span></a></li>
				<li class="settings"><a href="./settings.php" title="Settings"><span>Settings</span></a></li>
				<li class="aboutus"><a href="./aboutUs.php" title="About Us"><span>About Us</span></a></li>
			</ul>
		</div>
		<div id="logout"><a href="./logout.php">logout</a></div>
		<div id="main_content">
			<div class="content_header">
				<h2><span>User Settings</span></h2>
			</div>
			<div class="content_box_right">
			<div class="content_box_left">
			<div class="content_box">
			<div id="main_content_border">
				<form action="settings.php" method="post">
				<div class="topmasters">
<!-- prcess submit data -->
<?php
	//var_dump($_POST);
	if(isset($_POST['free_mem_h']) && $_POST['free_mem_h'] != '') {
		$urs_config->para['PCT_FREE_MEM'] = $_POST['free_mem_h']*1000000+$_POST['free_mem_u']*100;
		$urs_config->para['DIC_HR'] = $_POST['dic_cache_h']*1000000+$_POST['dic_cache_u']*100;
		$urs_config->para['PCT_RELOADS'] = $_POST['reload_h']*1000000+$_POST['reload_u']*100;
		$urs_config->para['BUFFER_HR'] = $_POST['buf_cache_h']*1000000+$_POST['buf_cache_u']*100;
		$urs_config->para['REDO_WAIT_R'] = $_POST['redo_wait_h']*1000000+$_POST['redo_wait_u']*100;
		$urs_config->para['IMM_ALLOC'] = $_POST['imm_alloc_h']*1000000+$_POST['imm_alloc_u']*100;
		$urs_config->para['IMM_COPY'] = $_POST['imm_copy_h']*1000000+$_POST['imm_copy_u']*100;
		$urs_config->para['WAIT_ALLOC'] = $_POST['wait_alloc_h']*1000000+$_POST['wait_alloc_u']*100;
		$urs_config->para['WAIT_COPY'] = $_POST['wait_copy_h']*1000000+$_POST['wait_copy_u']*100;
		$urs_config->para['PCT_SORTS'] = $_POST['sort_h']*1000000+$_POST['sort_u']*100;
		$urs_config->para['ROLLBACK'] = $_POST['rollback_h']*1000000+$_POST['rollback_u']*100;
		
		$urs_config->update();
		echo '<p><font color="green">You have updated all the parameters.</font></p>';
	}
?>
				<table class="one-column-emphasis">
					<thead>
						<tr>
							<th width="30%"><h2>Shared Pool</h2></th>
							<th>Healthy - Not very healthy</th>
							<th>Not very healthy - Attention</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>% of Free Memory: </td>
							<td><input type="text" name="free_mem_h" value="<?=$urs_config->getFirst('PCT_FREE_MEM')?>"/></td>
							<td><input type="text" name="free_mem_u" value="<?=$urs_config->getSecond('PCT_FREE_MEM')?>"/></td>
						</tr>
						<tr>
							<td>Dictionary Cache Hit Ratio: </td>
							<td><input type="text" name="dic_cache_h" value="<?=$urs_config->getFirst('DIC_HR')?>"/></td>
							<td><input type="text" name="dic_cache_u" value="<?=$urs_config->getSecond('DIC_HR')?>"/></td>
						</tr>
						<tr>
							<td>Proportion of Reloads: </td>
							<td><input type="text" name="reload_h" value="<?=$urs_config->getFirst('PCT_RELOADS')?>"/></td>
							<td><input type="text" name="reload_u" value="<?=$urs_config->getSecond('PCT_RELOADS')?>"/></td>
						</tr>
					</tbody>
				</table>
				
				<table class="one-column-emphasis">
					<thead>
						<tr>
							<th width="30%"><h2>Buffer Cache</h2></th>
							<th>Healthy - Not very healthy</th>
							<th>Not very healthy - Attention</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Buffer Cache Hit Ratio: </td>
							<td><input type="text" name="buf_cache_h" value="<?=$urs_config->getFirst('BUFFER_HR')?>"/></td>
							<td><input type="text" name="buf_cache_u" value="<?=$urs_config->getSecond('BUFFER_HR')?>"/></td>
						</tr>
					</tbody>
				</table>
				
				<table class="one-column-emphasis">
					<thead>
						<tr>
							<th><h2>Redo Log Buffer/Files</h2></th>
							<th>&nbsp;</th>
							<th>Healthy - Not very healthy</th>
							<th>Not very healthy - Attention</th>
						</tr>
					</thead>
					<tbody>
						<tr>
						    <th width="30%">Redo Space Wait Ratio</th>
							<th>&nbsp;</th>
					    	<td><input type="text" name="redo_wait_h" value="<?=$urs_config->getFirst('REDO_WAIT_R')?>"/></td>
						    <td><input type="text" name="redo_wait_u" value="<?=$urs_config->getSecond('REDO_WAIT_R')?>"/></td>
                        </tr>
						<tr>
						    <th width="30%" rowspan="4">Redo Log Contention</th>
							<td>Immediate Contention of Redo Allocation</td>
					    	<td><input type="text" name="imm_alloc_h" value="<?=$urs_config->getFirst('IMM_ALLOC')?>"/></td>
						    <td><input type="text" name="imm_alloc_u" value="<?=$urs_config->getSecond('IMM_ALLOC')?>"/></td>
                        </tr>
						<tr>
							<td>Immediate Contention of Redo Copy</td>
					    	<td><input type="text" name="imm_copy_h" value="<?=$urs_config->getFirst('IMM_COPY')?>"/></td>
						    <td><input type="text" name="imm_copy_u" value="<?=$urs_config->getSecond('IMM_COPY')?>"/></td>
                        </tr>
						<tr>
							<td>Wait Contention of Redo Allocation</td>
					    	<td><input type="text" name="wait_alloc_h" value="<?=$urs_config->getFirst('WAIT_ALLOC')?>"/></td>
						    <td><input type="text" name="wait_alloc_u" value="<?=$urs_config->getSecond('WAIT_ALLOC')?>"/></td>
                        </tr>
						<tr>
							<td>Wait Contention of Redo Copy</td>
					    	<td><input type="text" name="wait_copy_h" value="<?=$urs_config->getFirst('WAIT_COPY')?>"/></td>
						    <td><input type="text" name="wait_copy_u" value="<?=$urs_config->getSecond('WAIT_COPY')?>"/></td>
                        </tr>
					</tbody>
				</table>
				
				<table class="one-column-emphasis">
					<thead>
						<tr>
							<th width="30%"><h2>Memory Area used for Sorting</h2></th>
							<th>Healthy - Not very healthy</th>
							<th>Not very healthy - Attention</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Waits / Accesses to Rollback Segments: </td>
							<td><input type="text" name="sort_h" value="<?=$urs_config->getFirst('PCT_SORTS')?>"/></td>
							<td><input type="text" name="sort_u" value="<?=$urs_config->getSecond('PCT_SORTS')?>"/></td>
						</tr>
					</tbody>
				</table>
				
				<table class="one-column-emphasis">
					<thead>
						<tr>
							<th width="30%"><h2>Rollback Segments</h2></th>
							<th>Healthy - Not very healthy</th>
							<th>Not very healthy - Attention</th>
						</tr>
					</thead>
					<tbody>
						<tr>
							<td>Waits / Accesses to Rollback Segments: </td>
							<td><input type="text" name="rollback_h" value="<?=$urs_config->getFirst('ROLLBACK')?>"/></td>
							<td><input type="text" name="rollback_u" value="<?=$urs_config->getSecond('ROLLBACK')?>"/></td>
						</tr>
					</tbody>
				</table>
				<p>
				<input type="submit" style="margin-left:470px;cursor:pointer" value="Submit"/>
				</p>
                    <p />&nbsp;<br />
					
                  <div class="clearthis">&nbsp;</div>
				</div>
				</form>
              <!-- End of Top Masters Listing 1 -->
			</div>
			</div>
			</div>
			</div>
  
		</div>
  
      <!-- End of Main Content -->
  
  
      <div class="clearthis">&nbsp;</div>
  
  
      <!-- Start of Page Footer -->
  
      <div id="page_footer">
      Design by <a href="aboutUs.php">CS5226 Group</a>
      </div>
  
  </div>
  
  </body>
  </html>